import { Injectable } from '@angular/core';

import { NzDrawerService, NzModalService } from 'ng-zorro-antd';

@Injectable({
  providedIn: 'root'
})
export class ModalService {

  constructor(
    private drawerService: NzDrawerService,
    private modalService: NzModalService
  ) { }

  /**
   * drawerCreate() 方法参数配置
   * config = {
   *  title: '',
   *  width: '',
   *  maskClosable: Boolean,
   *  closable: Boolean,
   *  content: '组件',
   *  contentParams: Object
   * }
   **/
  drawerCreate(config): void {
    this.drawerService.create({
      nzTitle: config.title,
      nzWidth: config.width || '800px',
      nzMaskClosable: config.maskClosable || false,
      nzClosable: config.closable || true,
      nzContent: config.content,
      nzContentParams: config.contentParams
    });
  }

  modalCreate(config): void {
    this.modalService.create({
      nzTitle: config.title,
      nzContent: config.content,
      nzComponentParams: config.componentParams,
      nzOnOk: config.onOk,
      nzFooter: config.footer
    });
  }

}
